home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / PlayerPRO 4.4.1 / MADF Library 3.0 / RDriver.h < prev    next >
Text File  |  1995-04-07  |  9KB  |  320 lines

  1. /********************                        ***********************/
  2. //
  3. //    Player PRO 4.4x -- MAD Music Driver Definition
  4. //
  5. //    Library Version 3.0
  6. //
  7. //    To use with MusicLibrary for Think C & CodeWarrior
  8. //
  9. //    Antoine ROSSET
  10. //    16 Tranchees
  11. //    1206 GENEVA
  12. //    SWITZERLAND
  13. //    
  14. //    FAX:            (+41 22) 346 11 97
  15. //    Compuserve:        100277,164
  16. //    Internet:         rosset@dial.eunet.ch
  17. //
  18. /********************                        ***********************/
  19.  
  20. #define MAX_ARP             3
  21. #define NUMBER_FINETUNES     16
  22. #define NUMBER_NOTES        84
  23. #define AMIGA_CLOCKFREQ2    3575872L
  24.  
  25. #define MIN_PITCH            13L
  26. #define MAX_PITCH            1918L
  27.  
  28. #define MIN_VOLUME            0
  29. #define MAX_VOLUME            64
  30. #define MAXTRACK            32
  31. #define MAXINSTRU            64
  32. #define MAXPATTERN            200
  33. #define MAXPATTERNSIZE        1024
  34.  
  35. /********************                        ***********************/
  36. /***                  RInit Function parameter                     ***/
  37. /********************                        ***********************/
  38.  
  39. enum
  40. {
  41.     ASCSoundDriver = 1,
  42.     AWACSoundDriver,
  43.     MIDISoundDriver,
  44.     SoundManagerDriver    
  45. };
  46.  
  47. enum
  48. {
  49.     MonoOutPut = 1,
  50.     StereoOutPut,
  51.     TrueStereoOutPut    
  52. };
  53.  
  54. struct RInitDesc
  55. {
  56.     short                    TrackNo;            // from 2 to 32
  57.  
  58.     short                    OutPutBits;            // 8 or 16
  59.     long                    OutPutFrequency;    // rate44khz, rate22050hz, rate22khz, rate11khz, rate11025hz
  60.     short                    DriverMode;            // ASCSoundDriver, AWACSoundDriver, MIDISoundDriver or SoundManagerDriver
  61.     short                    SMBufferSize;        // Used only if DriverMode == SoundManagerDriver
  62.  
  63.     short                    VExt;                // Play Speed : 80 = normal
  64.     short                    FreqExt;            // Play Pitch : 80 = normal
  65.  
  66.     Boolean                    AntiAliasing;        // Use AntiAliasing filter ?
  67.     short                    OutPutMode;            // Mono, Stereo or True Stereo output ?
  68.  
  69.     Boolean                    RepeatMusic;        // If music finished, repeat it or stop.
  70. };
  71. typedef struct RInitDesc RInitDesc;
  72.  
  73.  
  74. /********************                        ***********************/
  75. /***                  Voice structure definition                    ***/
  76. /********************                        ***********************/
  77.  
  78. struct VoiceActive    {
  79.         Ptr            MaxPtr;
  80.         Ptr            InstruVoice;
  81.         Ptr            StartPtr;
  82.         long        loopWord;
  83.         long        loopWords;
  84.         
  85.         short        Instru;
  86.         short        InstruOld;
  87.         
  88.         short        fineTune;
  89.         
  90.         short        Amiga;
  91.         short        AmigaOld;
  92.         
  93.         short        pitch;
  94.         short         realpitch;
  95.         short        Prerealpitch;
  96.         
  97.         short        volume;
  98.         short         effect;
  99.         Byte        arg;
  100.         
  101.         short         arp[MAX_ARP];
  102.         short         arpindex;
  103.         
  104.         short        viboffset;
  105.         short         vibdepth;
  106.         short         slide;
  107.         short         pitchgoal;
  108.         
  109.         short         pitchrate;
  110.         short        oldpitchrate;
  111.         
  112.         short         volumerate;
  113.         
  114.         short         vibrate;
  115.         short        oldvibrate;
  116.         
  117.         short         retrig;
  118.         
  119.         short        ID;
  120.         short        amplitude;
  121.         
  122.         Ptr            samplePtr;
  123.         
  124.         Boolean        repeat;
  125. };
  126. typedef        struct VoiceActive    VoiceActive;
  127.  
  128. /********************                        ***********************/
  129. /***              Music description used in driver                ***/
  130. /********************                        ***********************/
  131.  
  132. struct    MADPartition
  133. {
  134.         MADSpec*                header;
  135.         struct    MusicPattern*    partition[ MAXPATTERN];
  136.         Ptr                        instrument[ MAXINSTRU];
  137. };
  138. typedef        struct MADPartition    MADPartition;
  139.  
  140. /********************                        ***********************/
  141. /***                    PlayerPRO variables                        ***/
  142. /********************                        ***********************/
  143.  
  144. #ifdef MainSystemPlayerPRO
  145. #define EXTDR
  146. #else
  147. #define EXTDR extern
  148. #endif
  149.  
  150. #ifndef __SOUND__
  151. #include <Sound.h>
  152. #endif
  153.  
  154. EXTDR    RInitDesc                InitDescInt;
  155. EXTDR    MADPartition            thePartition;                        // Current music in memory, loaded with RLoadMusic() by example
  156. EXTDR    MADSpec                    *theFileInt;                        // Current music header == thePartition.header
  157. EXTDR    VoiceActive                theVoiceActive[ MAXTRACK];            // Current driver voices
  158. EXTDR    short                    DriverTypeInt;                        // Actual driver type
  159. EXTDR    short                    Tube[ MAXTRACK];                    // Used in 'Tracks View' Window - View menu
  160. EXTDR    short                    PartitionReader;                    // Current position in pattern (0...64)
  161. EXTDR    short                    Pat;                                // Current ID Pattern, see 'Patterns list'
  162. EXTDR    short                    PL;                                    // Current position in partition, see 'Partition list'
  163. EXTDR    short                    VolExt[ MAXTRACK];                    // Volumes settings, see 'Adaptators' window
  164. EXTDR    short                    speed;                                // Current speed, see speed Effect
  165. EXTDR    short                    finespeed;                            // Current finespeed, see speed Effect
  166. EXTDR    short                    InstruTube[ MAXINSTRU];                // Used in 'Instrument View' Window - View menu
  167. EXTDR    short                    VExt;                                // External music speed, see 'Adaptators' window
  168. EXTDR    short                    FreqExt;                            // External music pitch, see 'Adaptators' window
  169. EXTDR    short                    DriveTrackNo;                        // Actual number of tracks
  170. EXTDR    short                    DriveOutBit;                        // Output bit: 8 or 16 bits
  171. EXTDR    Boolean                    PtrSystem;                            // Use NewPtr or NewPtrSys ?
  172. EXTDR    Boolean                    Reading;                            // Reading indicator
  173. EXTDR    Boolean                    MusiqueFertig;                        // Is your music finished?
  174. EXTDR    Boolean                    AntiAliasingFilter;                    // Is AntiAliasingFilter On? RInitMusic turns it to false
  175. EXTDR    short                    LeftRight[ MAXTRACK];                // Left/Right % for Deluxe Driver
  176.  
  177. /* DO NOT MODIFY OR USE these variables */
  178.  
  179. EXTDR    short                    smallcounter, trackDiv;
  180. EXTDR    long                    ASCBUFFER, FREQBASE;
  181. EXTDR    short                    **FreqHandle, InstruActif[ MAXINSTRU];
  182. EXTDR    Ptr                        SysHeapPtr, Vol, IntDataPtr, OscilloWavePtr;
  183. EXTDR    Boolean                    RepeatMusic, JumpToNextPattern;
  184. EXTDR    Boolean                    DriveStereo, PtrSystem, JumpToNextPattern, AntiAliasing;
  185. EXTDR    short                    pitchTable[ NUMBER_NOTES + 4][ NUMBER_FINETUNES];
  186. EXTDR    long                    VSYNC, BufCounter, BytesToGenerate;
  187.  
  188. extern    short vibrato_table[ ];
  189.  
  190.  
  191. /********************                        ***********************/
  192. /***                        DRIVERS ID                            ***/
  193. /***             DO NOT USE MIDIClassic Driver !!!!                ***/
  194. /********************                        ***********************/
  195.  
  196. enum {
  197.     ASCMono = 1,
  198.     ASCStereo = 2,
  199.     SMMono = 3,
  200.     SMStereo = 4,
  201.     SMDSP = 5,
  202.     SMPolyPhonic = 6,
  203.     MIDIClassic = 7,
  204.     AWAC = 8,
  205.     SMDELUXE = 9,
  206.     SMDELUXE8 = 10
  207. };
  208.  
  209. /********************                        ***********************/
  210. /***                        EFFECTS ID                            ***/
  211. /********************                        ***********************/
  212.  
  213. enum {
  214.         arpeggioE         = 0,
  215.         downslideE         = 1,
  216.         upslideE         = 2,
  217.         portamentoE     = 3,
  218.         vibratoE         = 4,
  219.         portaslideE     = 5,
  220.         vibratoslideE    = 6,
  221.         nothingE         = 7,
  222.         offsetE         = 9,
  223.         slidevolE         = 10,
  224.         fastskipE         = 11,
  225.         volumeE         = 12,
  226.         skipE             = 13,
  227.         extendedE         = 14,
  228.         speedE             = 15
  229.     };
  230.  
  231. /********************                        ***********************/
  232. /*                General Function Description                      */
  233. /*      For more informations about these functions, e-mail me    */
  234. /********************                        ***********************/
  235.  
  236.  
  237. /********************                        ***********************/
  238. /***                     EXTERNAL ROUTINES                         ***/
  239. /*** See Documentation for more informations on these routines  ***/
  240. /********************                        ***********************/
  241.  
  242. enum {
  243.     FileType = 1,
  244.     RsrcType = 2,
  245.     PtrType = 3
  246. };
  247.  
  248. #ifdef __cplusplus
  249. extern "C" {
  250. #endif
  251.  
  252. OSErr    RInitMusic( short, short, Boolean);            // Music Driver initialization
  253. OSErr    RPlayMusic( void);                            // Play the current music
  254. OSErr    RStopMusic( void);                            // Stop the current music
  255. OSErr    RResetMusic( void);                            // Reset the current music at the start position
  256. OSErr    RQuitMusic( void);                            // Dispose the music driver, use it after RInitMusic()
  257.  
  258. OSErr    RLoadMusic( Str255 fName);                    // Load a MAD File in the current directory
  259. OSErr    RLoadMusicRsrc( OSType IDName, short IDNo);    // Load a MAD Rsrc into memory
  260. OSErr    RLoadMusicPtr( Ptr myPtr);                    // Load a MAD Ptr into memory, you can DisposPtr your Ptr after this call
  261. OSErr    RInstallMADF( MADPartition aPartition);        // Install directly a MAD partition
  262. OSErr    RClearMusic(void);                            // Dispose the current music, use it after RLoadMusic(), RLoadMusicRsrc(), RInstallMADF()
  263.  
  264.  
  265. OSErr    ConvertMod2Mad( Ptr aMOD, long Size, MADPartition *theMAD);    // Convert MOD to MAD
  266. Ptr        ConvertMad2Mod( MADPartition *theMAD);                        // Convert MAD to MOD
  267. void    ChangeTrackNo( short);                                        // Change current tracks number of the music driver
  268. void    CleanDriver();                                                // Clean the driver
  269. struct Command* GetCommand( short PosX, short    TrackIdX, struct MusicPattern*    tempMusicPat);        // Extract a Command from a MusicPattern    
  270.  
  271. // Play a sound with an amplitude on a track at a period, with loopStart and loopEnd
  272. // If period == 0, play it at normal frequence 22Khz ( F#5 )
  273. // Period: from 0 to NUMBER_NOTES
  274. OSErr RPlaySound( Ptr whichSound, long SoundSize, long whichTrack, long Period, long Amplitude, long loopStart, long loopLength);
  275.  
  276.  
  277. /********************                        ***********************/
  278. /***                     INTERNAL ROUTINES                        ***/
  279. /***                DO NOT use these routines                    ***/
  280. /********************                        ***********************/
  281.  
  282. void    Sampler8in8Add( VoiceActive *curVoice, register Ptr    ASCBuffer);
  283. void    Sampler16Add( VoiceActive *curVoice, register short    *ASCBuffer);
  284.  
  285. void    NoteAnalyse( void);
  286.  
  287. void    ClearVol4();
  288. OSErr    SetUpFrequence( long, long);
  289. OSErr    ReadInstrument( short, short, Handle, Ptr);
  290. void    DoEffect( VoiceActive *, short);
  291. OSErr    DBSndClose();
  292. void    StopChannel();
  293. OSErr     SetMODVol4( long , long , Boolean );
  294. void    PlayChannel();
  295. void     checkpitch( VoiceActive *, Boolean);
  296. void     BufferCopyM();
  297. void     BufferCopyS();
  298. void    InstallMODVBL(void);
  299. void     ReadNote( VoiceActive *curVoice, struct Command        *theCommand);
  300. void    RemoveMODVBL(void);
  301. void    MODRelance(void);
  302. void    Play(void);
  303. void    VIAOn(void);
  304. void     SndOff(void);
  305. void     SndOn(void);
  306. void    VIAOn2(void);
  307. void     VIAOn3(void);
  308. OSErr    InitDBSoundManager( long);
  309. void     SetUpEffect( VoiceActive *ch);
  310. Boolean DirectSave( Ptr, short, short);
  311. void    ChangeSpeed( void);
  312. void    Play16Stereo( void);
  313. void    Play8Stereo( void);
  314. void    Play8Mono( void);
  315. void     ClearFrequence();
  316.  
  317. #ifdef __cplusplus
  318. }
  319. #endif
  320.